var app = getApp();
Page({
    data:{
		siteroot : app.siteInfo.siteroot.replace('app/index.php', ''),uniacid: app.siteInfo.uniacid,
        options : {},
    },
    onLoad:function(options){
        var self = this;
        var type = options.type ? options.type : '';
        var id = options.id ? options.id : '';
        if(options.scene) id = options.scene;

        self.data.options = options;

        app.com.http('advert','POST',{op:'info',type:type,id:id},30,false,'','',function(res){
            if (!res.data.errno && res.data) {
                self.setData({
                    content : res.data.data.content,
                    info : res.data.data.article,
                    sharedata : res.data.data.sharedata,
                    inited : true,
                });

                if( res.data.data.content ){
                    var octoparse = require('../resource/wxParse/html2json2.js');
                    var transData = octoparse.parse(self.data.content);                   
                    self.setData({
                        nodes : transData,
                    })
                }
                wx.setNavigationBarTitle({
                    title: res.data.data.article.title
                });
            }else{
                app.com.alert(res.data.message,function(){
                    app.com.backPage(0);
                });
            }
        });
    },
    onShareAppMessage : function(){
        var self = this;
        return {
            title: self.data.sharedata.title,
            path: self.data.sharedata.path,
            imageUrl : self.data.sharedata.img,
        }
    },
    onPullDownRefresh: function () {
        if( this.data.isdown ) return false;
        this.onLoad( this.data.options );
        this.setData({
            isdown : false,
        });
        wx.stopPullDownRefresh();
    },
    location : function( e ){
        app.com.location( e );
    },
    otherapp : function( e ){
        app.com.otherapp( e );
    },
    navigateto : function( e ){
        app.com.navigateto( e);
    },
    redirectto : function( e ){
        app.com.redirectto( e );
    },
    callphone : function(e){
        app.com.callphone( e );
    },
    showimages : function( e ){
        app.com.showimages( e );
    },
    footNavigate(e){
        var url = e.currentTarget.dataset.url;
        wx.switchTab({
          url: url
        })
    },
    
})